package com.fqgj.xjd.user.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fqgj.common.api.Response;
import com.fqgj.xjd.user.client.UserAadhaarService;
import com.fqgj.xjd.user.client.UserService;
import com.fqgj.xjd.user.client.request.UserAadhaarScoreInfo;
import com.fqgj.xjd.user.client.response.AadhaarScoreInfo;
import com.fqgj.xjd.user.client.response.Customer;
import com.fqgj.xjd.user.dao.UserAadhaarScoreDao;
import com.fqgj.xjd.user.entity.business.UserAdahaarScoreEntity;
import com.fqgj.xjd.user.job.AppListTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * User: pavan
 * Date: 2018/7/26
 * Time: 上午10:56
 */
@Controller
public class TestController {

    @Autowired
    private UserService userService;
    @Autowired
    private AppListTask appListTask;

    @Autowired
    private UserAadhaarService userAadhaarService;

    @Autowired
    private UserAadhaarScoreDao userAadhaarScoreDao;

    @RequestMapping("/test01")
    @ResponseBody
    public String test01() {
        Response<Customer> response = userService.getCustomerByIdentityNo("362330199009267270");
        return "ok+++:" + JSON.toJSONString(response);
    }

    @RequestMapping("/applist")
    @ResponseBody
    public String getAppAList() throws InterruptedException {
        appListTask.batchExecute(0,2000);

        return "ok";
    }


    @RequestMapping("/save")
    @ResponseBody
    public String save() throws InterruptedException {
        UserAdahaarScoreEntity userAdahaarScoreEntity = new UserAdahaarScoreEntity();
        userAdahaarScoreEntity.setUserCode("1234");
        userAdahaarScoreEntity.setScore("213141");
        userAdahaarScoreEntity.setReportUrl("hhah");
        userAdahaarScoreEntity.setSuccess(true);
        userAadhaarScoreDao.insert(userAdahaarScoreEntity);


        return "ok";
    }
}
